var add_submit = function(){
	var passUrlObj = {
		"issms":$("input[name='issms']:checked").val(),
		"ispage":$("input[name='ispage']:checked").val(),
		"remindDispDate":$("#remindDispDate").val(),
		"rmdHour":$("#rmdHour").val(),
		"rmdRetainDays":$("#rmdRetainDays").val(),
		"remindContent":$("#remindContent").val()
	};
	if(!passUrlObj.remindDispDate){
		showErrorMsg("提醒日期不能为空！");
		return false;
	}
	if(!passUrlObj.rmdRetainDays){
		showErrorMsg("保留天数不能为空！");
		return false;
	}
	var reg = /^\d+$/;
	if(!reg.test(passUrlObj.rmdRetainDays)){
		showErrorMsg("保留天数必须为数字!");
		return false;
	}
	if(!passUrlObj.remindContent){
		showErrorMsg("提醒内容不能为空！");
		return false;
	}

	//禁用提交按钮
	disabled_submit_button(true);

	var url = "issms="+passUrlObj.issms+"&ispage="+passUrlObj.ispage+"&";
	url += "remindDispDate="+passUrlObj.remindDispDate+"&rmdHour="+passUrlObj.rmdHour+"&";
	url +="rmdRetainDays="+passUrlObj.rmdRetainDays+"&remindContent="+encodeURI(passUrlObj.remindContent);

	var params ={"token":getParamValue("token"),"staffNo":getParamValue("EmpCode"),"passUrl":url};
	$.ajax({
		type: "post",
		contentType:'application/json; charset=UTF-8',
		data: JSON.stringify(params),
		url: Constants.rpcEsopHost+"addInitiativeRemind",
		dataType: "json",
		async: true,
		headers: {
      'token': getParamValue('token'),
      'saleType': getParamValue('saleType')
    },
    success: function(data) {
      if (data.ResultCode === 1009) {
        alert('登陆超时，请重新登录！');
        jumpToSignin();
        return;
      }
			console.log(data);
			disabled_submit_button(false);
			if(data.rtnCode!=1000){
				showErrorMsg(data.rtnMsg);
				console.log("提交数据到RPC接口失败！code:"+data.rtnCode);
				return;
			}
			if(data.return.resultCode!="00"){
				showErrorMsg(data.return.resultDesc);
				console.log("提交数据到信息接口失败！code:"+data.return.resultCode);
				return;
			}
			$("#submit_success").click();
		},
		error : function(textStatus) {
			showErrorMsg("提交数据失败！服务器没有返回。");
			disabled_submit_button(false);
			console.log("提交数据失败！服务器没有返回。");
		}
	});
}
var showErrorMsg = function(msg){
	$("#err_msg_info").html(msg);
	$("#submit_error").click();
}
$(function(){
	init_reminder_time();
});
var back_list = function(){
	window.location.href = "reminder.html" + "?" + getParams();
}
var disabled_submit_button = function(open){
		if(open){
			$("#submit_wite").click();
			$("#add_submit").html(" <img width='20px;' src='../../../img/progress.gif'> 提交中...");
			$("#add_submit").attr("disabled","disabled");
		}else{
			$("#wite_close").click();
			$("#add_submit").html("提交");
			$("#add_submit").removeAttr("disabled");
		}
};

var init_reminder_time = function(){
	var selectHtml = "";
	for(var i=1;i<=24;i++){
		selectHtml += "<option value='"+i+"'>"+i+"点</option>";
	}
	$("#rmdHour").html(selectHtml);
};
